package com.weather.androidweather;

import android.app.Application;
import android.util.Log;

import com.baidu.location.LocationClient;
import com.baidu.mapapi.CoordType;
import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.common.BaiduMapSDKException;

public class WeatherApplication extends Application {
    private static final String TAG = "WeatherApplication";

    @Override
    public void onCreate() {
        super.onCreate();
        Log.d(TAG, "WeatherApplication onCreate");
        
        try {
            // 设置同意隐私政策
            SDKInitializer.setAgreePrivacy(this, true);
            Log.d(TAG, "已设置同意隐私政策");
            
            // 初始化百度地图SDK
            SDKInitializer.initialize(this);
            // 设置坐标类型
            SDKInitializer.setCoordType(CoordType.BD09LL);
            
            // 设置API Key - 只需要Android API Key，不需要Web Service API Key
            SDKInitializer.setApiKey("NSFXzC4j5pxT9D9dKybQC9WVyMlZXaWy");
            
            Log.d(TAG, "百度地图SDK初始化成功");
            Log.d(TAG, "应用包名: " + getPackageName());
        } catch (BaiduMapSDKException e) {
            Log.e(TAG, "百度地图SDK初始化失败: " + e.getMessage());
            e.printStackTrace();
        }
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        Log.d(TAG, "WeatherApplication onTerminate");
    }
} 